<?xml version='1.0' encoding='UTF-8' ?> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core">

<h:head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />        
	<ui:insert name="headTitle"/>
</h:head>

<h:body style="font-size:14px">

		<p:dialog id="dlgAlterarSenhaMs" widgetVar="dlgAltSenha" header="Alterar Senha" 
   	          closable="true" modal="true" resizable="false" showEffect="fade" hideEffect="explode">
   	          <p:messages id="messages" showDetail="false" autoUpdate="true"/>
   	    </p:dialog>
   	    
   	    	<table width="100%">
				<tr>
					<td><ui:include src="menuPrincipal.xhtml" /></td>
				</tr>
			</table>
		
		<h:form id="formAlterarSenhaMs">	
			
		<table width="40%" align="center">
			<tr>
				<td>
					<p:panel header="Alterar a Senha">

					<h:panelGrid id="display" columns="2" cellpadding="4" style="margin:0 auto;">  
		  
		            <h:outputText value="Nova Senha:" />  
		            <p:password id="novaSenha" value="#{loginMB.login.senha}"  
		                    	required="true" requiredMessage="Por favor, especifique a nova senha."
		                    	promptLabel="Por favor, especifique a nova senha"
		                    	feedback="true" strongLabel="forte" goodLabel="boa" weakLabel="fraca"
		                    	validatorMessage="Senhas não conferem." match="confirmaSenha" size="10" maxlength="10"/>  
	
		            <h:outputText value="Confirmar Senha:" />  
		            <p:password id="confirmaSenha" value="#{loginMB.login.senha}"
		            			required="true" requiredMessage="Por favor, confirme a nova senha."
		                    	validatorMessage="Senhas não conferem." size="10" maxlength="10"/>  
		  
		            <f:facet name="footer">
		            	<p align="center">  
							<p:commandButton id="altButton" value="Alterar"    
						    	             actionListener="#{loginMB.alterarSenha}"
						    	             update=":formAlterarSenhaMs"
						    	             oncomplete="verificaAlterarSenha(xhr, status, args);"/>&nbsp;&nbsp;
						</p>
						<p><h:outputText value="#{loginMB.trocarSenha}" /></p>
					</f:facet>  
				
		        </h:panelGrid>		
		        </p:panel>	        
	       </td>
		</tr>
	</table>	
	  </h:form>

      	
		<script type="text/javascript">  
		    function verificaAlterarSenha(xhr, status, args) {  
		        if (args.validationFailed || !args.senhaAlterada) {  
		        } else {
		        	dlgAltSenha.hide();
		        }  
		    }  
		</script>        	
	
</h:body>

</html>